﻿using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.LIB;
using YJKCodeBase.WinForm;

namespace FamilyCompare
{
	public partial class FrmResultDetail : System.Windows.Forms.Form
	{
		public FrmResultDetail(DataTable inputDt)
		{
			FrmResultDetail.resultDt = inputDt;
			this.InitializeComponent();
		}

		public FrmResultDetail(DataTable inputDt, WindowHandle revitHandle)
		{
			FrmResultDetail.resultDt = inputDt;
			this.m_RevitHandle = revitHandle;
			this.InitializeComponent();
		}

		private void FrmResultDetail_Load(object sender, EventArgs e)
		{
			//base.Icon = Resource.YArchitechIcon;
			this.DataGridViewDataInit();
		}

		private void dgvResultDetail_Resize(object sender, EventArgs e)
		{
			this.dgvResultDetail.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
		}

		private void DataGridViewDataInit()
		{
			for (int i = 0; i < FrmResultDetail.resultDt.Columns.Count; i++)
			{
				this.dgvResultDetail.Columns.Add(FrmResultDetail.resultDt.Columns[i].ColumnName, FrmResultDetail.resultDt.Columns[i].ColumnName);
			}
			for (int j = 0; j < FrmResultDetail.resultDt.Rows.Count; j++)
			{
				DataGridViewRow dataGridViewRow = new DataGridViewRow();
				dataGridViewRow.CreateCells(this.dgvResultDetail);
				for (int k = 0; k < FrmResultDetail.resultDt.Columns.Count; k++)
				{
					DataGridViewCell dataGridViewCell = dataGridViewRow.Cells[k];
					dataGridViewCell.Value = FrmResultDetail.resultDt.Rows[j][k].ToString();
				}
				if (FrmResultDetail.resultDt.Rows[j][1].ToString() != FrmResultDetail.resultDt.Rows[j][2].ToString())
				{
					dataGridViewRow.DefaultCellStyle = new DataGridViewCellStyle
					{
						ForeColor = Color.Red
					};
				}
				this.dgvResultDetail.Rows.Add(dataGridViewRow);
			}
		}

		private void btnSure_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private void btnCancle_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private void FrmResultDetail_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\u001b')
			{
				base.Close();
			}
		}

		private static DataTable resultDt;

		private WindowHandle m_RevitHandle;
	}
}
